home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / MATHEMAT / 1769.ZIP / PFSA.DOC < prev    next >
Text File  |  1988-10-05  |  26KB  |  668 lines

  1.                                TABLE OF CONTENTS
  2.  
  3.  
  4.  
  5.     I    Introduction                   2
  6.  
  7.     II   Usage                          2
  8.  
  9.     III  Examples                       4
  10.  
  11.          A  Basic Commands              4
  12.  
  13.          B  Procedures                  4
  14.  
  15.          C  Canonical Transformation    5
  16.  
  17.          D  Binomial Expansion          6
  18.  
  19.          E  Inversion of Series         6
  20.  
  21.     IV   Commands                       9
  22.  
  23.     V    Error Messages                13
  24.  
  25.     VI   Technical Details             14
  26.  
  27.                                       -2-
  28.  
  29.     I.  INTRODUCTION
  30.  
  31.          The PFSA program was created to do some rather large but simple
  32.     algebraic computations.  PFSA does not have the large variety of
  33.     commands which more general purpose symbolic algebra programs (muMath
  34.     and Macsyma) have but it is faster and can work with bigger
  35.     expressions.  PfSA ran 90 times faster than Macsyma on a very large
  36.     Hamiltonian canonical transformation project, and it runs more than 200
  37.     times faster than muMath when doing example E.  PFSA is written in
  38.     Fortran and the arithmetic involving coefficients of terms is done with
  39.     the Fortran arithmetic.  Two versions are provided, one which uses only
  40.     rational integer*4 arithmetic (PFSAI.EXE) and another (PFSAF.EXE) which
  41.     uses real*8 arithmetic during calculation of coefficients.  The author
  42.     is working on an extended precision version.
  43.  
  44.          The EXE versions on this PC Blue disk need 300K to run.  The
  45.     program can be compiled with different values for parameters (in
  46.     dimension statements) to get a smaller executable file or to get
  47.     capability to handle bigger expressions.  If you find a bug and want to
  48.     report it to the author, put a minimal example "algin" file on a floppy
  49.     and send it to: Don Stevens, 4 Wash. Sq. Village, NY NY 10012.  If you
  50.     want the floppy returned please include a stamped return envelope.
  51.     Revised versions may be available in the future.
  52.  
  53.          The author of PFSA tried to make the usage of PFSA simple.  PFSA
  54.     reads a file "algin", processes the commands therein, and produces a
  55.     file "algout".  The commands in the algin file are mostly close enough
  56.     to ordinary English so that the algebra to be performed is clear even
  57.     to an inexperienced reader.  PFSA commands allow one to do standard
  58.     operations on polynomial expressions (addition, subtraction,
  59.     multiplication, selection of portions of expressions, substitutions,
  60.     differentiation).  Binomial expansions may be generated with
  61.     non-integer exponents.  Numerical evaluation may be done by doing
  62.     substitutions.  Procedures may be defined.  The commands are listed and
  63.     described in Section IV.  Section III is intended to be a tutorial for
  64.     new users of PFSA.  Section V is a listing of some error messages and
  65.     their meaning.  Section VI contains technical details of little
  66.     interest to most users.
  67.                                       -3-
  68.  
  69.     II.  USAGE
  70.  
  71.          The user prepares a file "algin" which contains commands that
  72.     specify the task to be done by PFSA.  The first command should be the
  73.     "order" command and the last command is the "end input" command.  The
  74.     commands of PFSA have been chosen so that the algin file will be
  75.     approximately a description of the problem in English.  A comment line
  76.     may be inserted by beginning the line with ";" or "*", or a comment may
  77.     be included on a command line after the command by beginning the
  78.     comment with a ";".  The user runs PFSA, which produces an output file
  79.     "algout".  The user can control the amount of output which PFSA
  80.     produces during a run by specifying a parameter (named "np").  If np=0
  81.     only error messages are produced.  After np=1 output from "print" and
  82.     "fortran" commands is produced.  After np=2 the commands are listed as
  83.     they are encountered.  After np=3 time and memory usage information is
  84.     printed after each command is done.
  85.  
  86.          There are three types of objects in PFSA: variables, sums, and
  87.     labels.  A product of variables with a coefficient is called a term,
  88.     and a sum of terms (perhaps only one) is called a sum.  Locations may
  89.     be designated by using the "label" command, and can be referred to by
  90.     the "goto" command.  The names of variables, sums, and labels should
  91.     begin with a letter and should not contain any of the following
  92.     characters: ; + - * / = .  Upper case and lower case are distinguished.
  93.     The default maximum length of names is 15 characters.  It is
  94.     recommended that no names begin with "flu", "lab", or "pro", see the
  95.     discussion at the start of Section IV.
  96.  
  97.          The first command in an algin file should be "order", for example:
  98.     order var1 var2 var3.  This command can be used only once per run.  The
  99.     effects of the above command are:
  100.     1.  In all terms printed, var1 would precede var2, which would precede
  101.         var3.
  102.     2.  All sums printed will be ordered first on the exponent of var1
  103.         (smaller exponents precede larger exponents), then on the exponent
  104.         of var2, etc.
  105.     3.  If subsequently the command    maxe = 2    were given, thereafter
  106.         whenever a term containing var1 raised to a power greater than 2 is
  107.         generated during a computation, this term would be discarded.
  108.         Previously defined sums are not affected.  Only var1 is affected.
  109.  
  110.          The commands "compute" and "define" have some overlap in their use
  111.     but the following distinctions should be noted.  The "compute" command
  112.     is always a one line command operating on sums only, while the "define"
  113.     command may be many lines and may operate on variables also.  Only the
  114.     "compute" command may be used to raise a sum to a non-integer power
  115.     (binomial expansion) or to divide one sum by another sum.
  116.                                       -4-
  117.  
  118.     III.  EXAMPLES
  119.  
  120.          The following examples give the flavor and style of usage of PFSA.
  121.     Section IV has descriptions of the full set of commands for PFSA.  This
  122.     section is intended to introduce the use of PFSA, not specify it.
  123.     Refer to Section IV for more exact definitions.  The examples are algin
  124.     files which may be run using PFSAI.EXE.  The algin files can be run
  125.     with PFSAF.EXE if all the fractional numbers are changed to decimal
  126.     numbers (Fortran real numbers).
  127.  
  128.  
  129.  
  130.          A.   Basic Commands
  131.      
  132.     order x y
  133.     define sum1 = 3/4 x**2
  134.     define sum2
  135.     1
  136.     4 sum1
  137.     7 y
  138.     1/3 z
  139.      
  140.     define sum3 = sum1 * sum2
  141.     print sum3
  142.      
  143.     the derivative of y wrt x is dydx
  144.     differentiate sum4 = d sum3/d x
  145.     print sum4
  146.     substitute 8 for x in sum4
  147.     print sum4
  148.      
  149.     fortran sum4
  150.      
  151.     define one = 1
  152.     define six = 6
  153.     define i = one
  154.      
  155.     label lab2
  156.     compute i = i + one
  157.     print i
  158.     if i.eq.six end
  159.     goto lab2
  160.      
  161.     end input
  162.      
  163.          B.   Procedures
  164.      
  165.     order x y z
  166.     *  This example contains a procedure which computes factorials.
  167.     *  The lines from "procedure factorial" to "return" define the
  168.     *  procedure.  There is no provision for local variables or
  169.     *  sums in procedures.  The sum "facarg" is used to
  170.     *  transmit the argument, and the sum "facans" is used to
  171.     *  transmit the answer.
  172.      
  173.                                       -5-
  174.  
  175.     procedure factorial
  176.     np=0     ;After this command only error messages are printed.
  177.     define one=1
  178.     define facans=one
  179.     if facarg.eq.one goto facend
  180.     define temp=facarg
  181.     if temp.lt.one bomb
  182.     label fact1
  183.     compute facans=facans*temp
  184.     compute temp=temp-one
  185.     if temp.ne.one goto fact1
  186.     label facend
  187.     np=2     ;after this command the usual printing resumes
  188.     return
  189.      
  190.     define facarg=5
  191.     call factorial
  192.     print facans
  193.     end input
  194.  
  195.  
  196.          C.  Canonical Transformation
  197.  
  198.          Here we will find a transformation of coordinates (p,q) to
  199.     coordinates (pb,qb) which transforms an expression
  200.     h=p**2 + q**2 +8*e*p*q to a better form in which there is no term
  201.     having e to the first power.  Here the transformation is specified by
  202.     the generating function f=pb*q + e*pb**2 - e*q**2; the transformation
  203.     is defined by p=df/dq, qb=df/dpb.  One must start from these two
  204.     equations and work out the transformation explicitly.
  205.  
  206.      order e p q pb qb
  207.      *  e is a small parameter (epsilon)
  208.      define h
  209.        p^2
  210.        q^2
  211.        8 e p q
  212.      
  213.      define f
  214.        pb q
  215.        e pb^2
  216.        -e q^2
  217.      
  218.      differentiate dfdq = d f/ d q
  219.      differentiate dfdpb = d f/ d pb
  220.      print dfdq
  221.      print dfdpb
  222.      *  There is no "solve" command in PFSA, one can use various
  223.      *  commands such as "compute" and "extract" to aid in big
  224.      *  computations.  Here we see by a simple calculation:
  225.      *  q=qb - 2 e pb  and p=pb - 2 e qb + 4 e^2 pb .
  226.      define qequals
  227.        qb
  228.        -2 e pb
  229.      
  230.                                       -6-
  231.  
  232.      define pequals
  233.        pb
  234.        -2 e qb
  235.        4 e^2 pb
  236.      
  237.      substitute qequals for q in h
  238.      substitute pequals for p in h
  239.      print h
  240.      
  241.      *  We see that the e term was eliminated.  More transformations
  242.      *  can be done to eliminate other unwanted terms.
  243.      end input
  244.  
  245.  
  246.          D.  Binomial Expansion
  247.      
  248.     order x
  249.     define mhalf = -.5    ;this example should be run with PFSAF.EXE
  250.     maxe=30
  251.     nbinomial=30
  252.     define aa
  253.     1
  254.     -x^2
  255.      
  256.     compute sb = aa^mhalf
  257.     substitute t for x in sb
  258.     the derivative of y wrt t is sb
  259.     define arcsin = y
  260.     taylor order = 31
  261.     taylor expand arcsin in t
  262.     substitute 0 for y in arcsin
  263.     substitute x for t in arcsin
  264.     print arcsin
  265.      
  266.     substitute .5 for x in arcsin
  267.     define pi = 6.*arcsin
  268.     print pi  ;accurate to 10 decimal places
  269.     end input
  270.  
  271.  
  272.          E.  Inversion of Series
  273.      
  274.     *  if y = x + b1 x^2 + b2 x^3 ... is given, this routine finds
  275.     *     x = y + c1 y^2 + c2 y^3 ... in general terms.
  276.     *  This example was contributed by Kaya Imre. PFSAI does this
  277.     *  example in 40 seconds on the XT (Microsoft compiler).  PFSAI
  278.     *  does this example in 29 seconds on a Cromemco (8 Mhz 68000).
  279.     *  The equivalent code in muMath runs in 11160 seconds on the XT.
  280.     *  The muMath code (also by Imre) is given after the algin file.
  281.                                       -7-
  282.  
  283.     order x y
  284.     np=1
  285.     def gen
  286.     x
  287.     b1 x^2
  288.     b2 x^3
  289.     b3 x^4
  290.     b4 x^5
  291.      
  292.     def rev
  293.     y
  294.     c1 y^2
  295.     c2 y^3
  296.     c3 y^4
  297.     c4 y^5
  298.      
  299.     def one = 1
  300.     def two = 2
  301.     def zero= 0
  302.     def yy  = y
  303.     def dup = rev / yy
  304.     com dup = dup - one
  305.     maxe = 6
  306.     sub gen for y in rev
  307.     def cnt = 0
  308.     def six = 6
  309.     def ex  = x
  310.     def rrev= y
  311.     def yp  = y
  312.      
  313.     lab loop
  314.     def tem = rev
  315.     sub q for x in tem
  316.     sub 0 for q in tem
  317.     com rev = rev - tem
  318.     def rev = rev / ex
  319.     com cnt = cnt + one
  320.     if cnt.le.two goto loop
  321.     def yp = yp * yy
  322.     def dup = dup / yy
  323.     def cc  = dup
  324.     sub 0 for y in cc
  325.     com dup = dup -cc
  326.      
  327.     sub zero for cc in tem
  328.     def tt  = -tem
  329.     sub tt for cc in rev
  330.     def rr  = -tem * yp
  331.     com rrev= rrev + rr
  332.     np = 2
  333.     pri rr
  334.     np = 0
  335.     if cnt.lt.six  goto loop
  336.     end input
  337.                                       -8-
  338.  
  339.     FUNCTION INVRT(F,G,N),
  340.     GG:G,
  341.     GH:G,
  342.     H:(EXPAND(EVSUB(G,Y,F))/X-1)/X,
  343.     GH:(GH/Y-1)/Y,
  344.     LOOP
  345.     WHEN N EQ 0 EXIT,
  346.     COEF:EVSUB(GH,Y,0),
  347.     AA:COEF-EVSUB(H,X,0),
  348.     H:EVSUB(H,COEF,AA)/X,
  349.     GH:(GH-COEF)/Y,
  350.     GG:EVSUB(GG,COEF,AA),
  351.     N:N-1,
  352.     ENDLOOP,
  353.     GG
  354.     ENDFUN$
  355.      
  356.     RDS()$
  357.                                       -9-
  358.  
  359.     IV.  COMMANDS
  360.  
  361.          The input for PFSA is fairly free form.  All commands should be in
  362.     lower case.  Commands may be abreviated.  The first 3 letters of the
  363.     command name are sufficient to identify the command, but some commands
  364.     require additional words in the command line.  PFSA reads the algin
  365.     file in segments (delimited by the "flush" command), and looks for
  366.     certain commands during this buffer filling.  If a line has "flu" or
  367.     "lab" or "pro" as the first non blank characters it will be interpreted
  368.     as a command by the preprocessor (generating an error if this were in
  369.     fact part of a "define" or an "order" block).  A line that starts with
  370.     an asterisk or semi-colon in column 1 will be considered by PFSA to be
  371.     a blank line.  PFSA will ignore blank lines, except those blank lines
  372.     used to terminate "define" or "order" blocks.
  373.  
  374.          In the following descriptions v1, v2, and v3 represent variables,
  375.     and s1, s2 and s3 represent sums.  The listed constructions are the
  376.     only valid constructions, for example there is no valid "compute"
  377.     construction involving a variable.  Vors1 and vors2 are used to
  378.     indicate that a variable or a sum may be used.
  379.  
  380.  
  381.     call label1
  382.      
  383.     compute s1=s2
  384.     compute s1=s2+s3
  385.     compute s1=s2-s3
  386.     compute s1=s2*s3
  387.     compute s1=s2/s3
  388.          The above division is done only if the result is expressible as a
  389.          sum of terms.  So if s3 contained only a single term the division
  390.          would be done.  If s3 has more than one term then if possible s1
  391.          will be found such that s1*s3 is equal to s2 up to order maxe in
  392.          the first variable.  This is not implemented for maxe greater than
  393.          2.  So if for instance maxe=2, s2=1, and s3=1+var1, then s1 will
  394.          be 1 - var1 + var1**2.
  395.     compute s1=s2^s3
  396.          S1 will be the binomial expansion of s2 to order nb(nbinomial).
  397.          S2 must have its first term equal to 1, so variable#1 cannot
  398.          appear in s2 with a negtive exponent.  If we write s2=1+z and if
  399.          s3=a, then s1 will be
  400.          1+a*z+a(a-1)z^2/2+..+a(a-1)..(a-nb+1)z^nb/nb!.
  401.      
  402.     count s1 = terms in s2
  403.          This command causes the number of terms in s2 to be counted and s1
  404.          is set equal to this number.
  405.      
  406.     define s1=coefficient vors1 vors2 ....
  407.          In the above form of the define command, "coefficient" represents
  408.          a rational number (or integer or nothing) and vors1 and vors2 are
  409.          variables or sums (perhaps with exponent).  The above form may not
  410.          be used if s1 has more than one term, in which case the form below
  411.          should be used.
  412.                                      -10-
  413.  
  414.     define s1
  415.      coefficient vors1 vors2 ....
  416.      coefficient vors1 vors2 ....
  417.      ..
  418.      (blank line to terminate sequence of terms)
  419.      
  420.     delete s1 s2 ...
  421.         Variables can not be deleted or used as a sum.
  422.      
  423.     derivative specification is done with the "the derivative..." command,
  424.         see below.
  425.      
  426.     differentiate s1=d s2 / d v1
  427.     differentiate s1=d s2 / d v1  order=number
  428.         The order of the derivative to be taken can also be specified by a
  429.         sum s3 which has been set equal to a positive integer, shown below.
  430.     differentiate s1=d s2 / d v1  order=s3
  431.      
  432.     dump
  433.      
  434.     end
  435.     end input
  436.         PFSA reads input lines in algin until it reaches "end input".
  437.      
  438.     extract s1 = term s2 of s3
  439.          In the above form s2 should be a sum which is currently equal to a
  440.          positive integer.  In the form below i and j are integers, and
  441.          there are no spaces between these integers and the "-".
  442.     extract s1 = terms i-j of s2
  443.      
  444.     flush
  445.          The input file algin is stored in a buffer in the running program.
  446.          If algin is too long to fit completely in the buffer, it should be
  447.          segmented using the flush command.  When this command is executed
  448.          the previous buffer contents are discarded and the next segment is
  449.          read in.  The call and goto commands are valid only for labels in
  450.          the current segment.  However, all information about variables and
  451.          sums is kept.
  452.      
  453.     fortran s1
  454.         S1 will be printed in a form suitable for use in a fortran program.
  455.      
  456.     goto label1
  457.      
  458.     if s1.eq.s2 command
  459.     if s1.ne.s2 command
  460.          The above constructions test whether s1 and s2 are identically
  461.          equal; if the relation is true, the command is executed.  The
  462.          command should be a one line command.  One may use the other
  463.          fortran relational operators .lt.  .le.  .gt.  and .ge.  but in
  464.          these cases only the first coefficients of s1 and s2 are compared.
  465.                                      -11-
  466.  
  467.     integration such as z = integral y dx may be done by:
  468.          (1) the deriv of q wrt x is y
  469.          (2) taylor expand q in x
  470.          (3) define z = q
  471.          (4) subst 0 for q in z
  472.      
  473.     label label1
  474.          The next line has label=label1.
  475.      
  476.     maxe = i
  477.          After this command, any terms newly arising which have variable#1
  478.          to a higher power than i will be discarded.
  479.      
  480.     nbinomial=i
  481.          Binomial expansions will be done to order i.
  482.      
  483.     ndump=0  No dump
  484.     ndump=1  A dump will occur after fatal errors.
  485.      
  486.     np=0  only error messages are printed
  487.     np=1  the above plus results of "print" and "fortran"
  488.     np=2  the above plus all commands are printed
  489.     np=3  the above plus time and memory usage are printed
  490.  
  491.  
  492.          The "first" variable must be specified at the start of an algin
  493.          file by the order command.  Other variables will be ordered
  494.          according to the order in which they are encountered as the algin
  495.          file is processed, and they need not be listed in the order
  496.          command.
  497.     order v1 v2...
  498.          The above form of the order command can be used if the list
  499.          v1 v2...  fits on one line.  If there are more variables to be
  500.          ordered than will fit on one line, use the following form:
  501.     order
  502.      v1 v2 ....
  503.      ..  ...
  504.      (blank line to terminate the list of variables)
  505.      
  506.     print s1
  507.      
  508.     procedure label1
  509.          All the lines between the above command and the "return" command
  510.          constitute the procedure with the name label1.  The procedure can
  511.          be invoked in the segment (see the flush command) where it occurs
  512.          by the call command.  Procedures should not call other procedures.
  513.          All names are global and available to to the procedure.
  514.     return
  515.                                      -12-
  516.  
  517.     substitute number for v1 in s1
  518.     substitute v1 for v2 in s1
  519.     substitute s1 for v1 in s2
  520.          In the above command, if v1 occurs to a negative power somewhere
  521.          in s2 and s1 has more than one term, an error message is printed
  522.          and the substitution is not done.
  523.     substitute v1 for s2 in s3
  524.     substitute s1 for s2 in s3
  525.          A limited form of pattern matching is provided by the above
  526.          command.  It is possible to replace any pattern which is
  527.          constituted of a single term.  If a substitute command is given in
  528.          which the pattern is a sum s2 with more than one term, the first
  529.          term (of sum s2) is examined and used in searching for matches and
  530.          the remainder of the terms (in sum s2) are ignored.
  531.      
  532.     taylor expand s1 in v1 v2 ..
  533.          The order of the taylor expansion wanted should have been
  534.          previously specified by the following command:
  535.     taylor order = i
  536.          where i is a positive integer or a sum.  The expansion is made
  537.          about v1=v2=..=0.
  538.      
  539.     the derivative of v1 wrt v2 is vors1
  540.          The above command is used to tell PFSA the derivatives of
  541.          variables.  Subsequently PFSA will use this information when
  542.          differentiating expressions containing these variables.  If the
  543.          derivative vors1 is a sum, a "chain rule" will stop at the sum
  544.          because the substitution of the sum into the place where it will
  545.          eventually go is not done until all chaining is finished.
  546.                                      -13-
  547.  
  548.     V.  ERROR MESSAGES
  549.      
  550.     bad cmnd    bad command
  551.      
  552.     call        an undefined label used in "call" command
  553.      
  554.     comput1     bad syntax in "differentiate" command
  555.     comput2     invalid numerical order of differentiation specified
  556.     comput3     no "/" found in "differentiate" command
  557.     comput4     right hand side not a sum in "compute s1=s2" command
  558.     comput14    order specified incorrectly in "differentiate" command
  559.     comput15    the order for differentiation should be positive
  560.     comput16    the order for differentiation should be an integer
  561.      
  562.     count1      bad syntax in "count" command
  563.     count2      final argument in "count" command should be a sum
  564.      
  565.     deriv2      the thing to be differentiated should be a sum
  566.     deriv4      in doing differentiation a chain rule sequence longer
  567.                 than 5 encountered
  568.      
  569.     expnd1      the item to be raised to a power is not a sum
  570.     expnd2-3    the first term of the item must be 1
  571.      
  572.     extrct1     the final argument in "extract" command should be a sum
  573.     extrct2     a non-reasonable term was requested in "extract" command
  574.     extrct5     bad syntax in "extract" command
  575.     extrct6     terms can be extracted only from sums
  576.     extrct7     j is less than i in "extract s1=terms i-j of s2
  577.      
  578.     gcdout1     an arithmetic mistake has occurred, a denominator is negative
  579.      
  580.     getexp2     input line too long
  581.     getexp4     bad syntax in input line
  582.     getexp6     input line too long
  583.     getexp8     bad syntax in input line
  584.     getexp9     input line too long
  585.      
  586.     iftest1-5   bad syntax in "if" command
  587.      
  588.     max jp      a sum is being raised to a power greater than 30 in a
  589.                 substitution process.  Change PFSA or algin to fix this.
  590.      
  591.     monitr2-6   bad command
  592.     monitr7     a label was searched for and not found in current segment
  593.     monitr8-10  bad command
  594.                
  595.     nxt         bad syntax in input line
  596.     nxtch       bad syntax in input line
  597.     nxtnb       bad syntax in input line
  598.                
  599.     print2      exponents greater than 99 are not handled by print routine
  600.     print3      a term is requiring too many characters in being printed
  601.                                      -14-
  602.  
  603.     putfirst    the "order" command should be the first command and should
  604.                 occur only once.
  605.      
  606.     readin2-10  bad syntax in substitute command
  607.     readin12    one should not substitute a number for a sum.  Use a term as
  608.                 intermediate substitution.
  609.      
  610.     return?     bad command
  611.     taylor1     bad value for order in "taylor" command
  612.     taylor2-5   bad syntax in "taylor" command
  613.     taylor6     only sums can be taylor expanded by PFSA
  614.      
  615.     term1       input line too long
  616.      
  617.     thderv1-2   bad syntax in "the derivative" command
  618.      
  619.     useorder    the first command in the algin file should be "order"
  620.                                      -15-
  621.  
  622.     VI.  TECHNICAL DETAILS
  623.  
  624.          The fortran source files are included so that users can
  625.     change the size or otherwise modify PFSA?.EXE as wanted.  The compiled
  626.     PFSA?.OBJ should be linked with TSUBS.OBJ (obtained by assembling
  627.     TSUBS.ASM) to produce PFSA?.EXE.
  628.  
  629.          The main routine calls subroutine "monitr" which reads in and
  630.     executes segments of the "algin" file.  The segments are delimited by
  631.     the "flush" command, the last segment is delimited by the "end input"
  632.     command.  Each segment is kept in memory while it is being executed,
  633.     and so target locations for "goto" and "call procedure" commands should
  634.     be in the same segment as the command.  (For machines which allow large
  635.     memory usage this can be avoided by using a single segment.) The
  636.     routine "monitr" examines input lines, decides which command is
  637.     intended, and calls the appropriate subroutine to execute the command.
  638.  
  639.          The sums and variables are referenced through a single set of
  640.     lists: list "pv" has the print form of the name, list "ittb" is zero
  641.     for variables and has the beginning term for sums, list "itte" has the
  642.     number of the final term for sums, list "ios" has the ordinal position
  643.     in memory for the sums.  So for example if ittb(1)=30, itte(1)=30,
  644.     ittb(2)=3, itte(2)=29, ittb(3)=1, itte(3)=2, the first two terms in the
  645.     list of terms constitute sum number 3 the next 27 terms constitute sum
  646.     number 2 and term 30 constitutes sum number 1, and ios(1)=3, ios(2)=2,
  647.     ios(3)=1.  An inverse of ios is kept in list "iosi".  A given sum name
  648.     will keep the same sum number (unless it is deleted and reintroduced)
  649.     but it may be moved to different positions in the list of terms.  The
  650.     coefficients of terms are kept in the list "tm" and pointers to the
  651.     list of factors and powers are kept in lists "itb" and "ite".
  652.  
  653.          After every command all the sums are put into a canonical sorted
  654.     order, which is the same order as is displayed when the sum is printed.
  655.     All sorting is done from start to end and if an out of sequence term is
  656.     found the correct location is found by a binary search and then the
  657.     pointers are changed for the affected terms.  When terms are created
  658.     during a multiplication or substitution command the above ordering
  659.     procedure is done.  At the end of generating the terms a packing
  660.     operation is done (by a routine named "pack") which arranges all terms
  661.     in memory so the pointers are ordered.
  662.  
  663.          Derivatives are handled by keeping a list of derivatives of
  664.     variables and searching this list (up to 5 deep) for all chains which
  665.     end with the given independent variable.  Of course, the program knows
  666.     d x**n/ dx, but other derivatives (if any) must have been previously
  667.     specified by a "the derivative of u wrt x is smthng" command.
  668.